package com.huoyun.userAdmin.dao;

import java.util.List;

import com.huoyun.base.dao.BaseDaoImpl;
import com.huoyun.userAdmin.bean.Address;

public class AddressDaoImpl extends BaseDaoImpl<Address> implements AddressDao{

	@Override
	public long saveAddress(Address address) 
	{
		sqlSessionTemplate.insert("com.huoyun.userAdmin.dao.AddressDaoMapper.saveAddress", address);
		return address.getId();
	}

	@Override
	public List<Address> getAddressByUserId(long userId) 
	{
	    return sqlSessionTemplate.selectList("com.huoyun.userAdmin.dao.AddressDaoMapper.getAddressByUserId", userId);
	}
	
	@Override
	public Address getAddressById(long addressId)
	{
		return sqlSessionTemplate.selectOne("com.huoyun.userAdmin.dao.AddressDaoMapper.getAddressById", addressId);
	}

	@Override
	public void update(Address address) 
	{
		sqlSessionTemplate.update("com.huoyun.userAdmin.dao.AddressDaoMapper.update", address);
	}

	@Override
	public void delete(long id) 
	{
		sqlSessionTemplate.delete("com.huoyun.userAdmin.dao.AddressDaoMapper.delete", id);
	}

}
